package com.ycd.com.ycd.feignclient;

import com.ycd.domain.User;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class UserFallbackFactory implements FallbackFactory<UserFeignClient> {
    @Override
    public UserFeignClient create(Throwable throwable) {
        return new UserFeignClient() {
            @Override
            public User add(Long id) {
                Date date = new Date();
                return new User(-1l, "服务熔断触发", "网络异常，请稍后重试！",date);
            }
        };
    }
}
